﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using Grundy.Common;

namespace Grundy.Message
{
    
    [DataContract]
    public class CountedFloatingLicense : FloatingLicense
    {
        public CountedFloatingLicense()
        {
            FloatingLicenseLimitTypeValue = FloatingLicenseLimitType.None.ToString();
        }

        public override string Type { get { return "Counted Floating"; } }

        
        [IgnoreDataMember]
        [Required]
        public string FloatingLicenseLimitTypeValue { get; set; }

        [DataMember]
        public FloatingLicenseLimitType LimitType
        {
            get { return (FloatingLicenseLimitType) Enum.Parse(typeof(FloatingLicenseLimitType), FloatingLicenseLimitTypeValue); } 
            set { FloatingLicenseLimitTypeValue = value.ToString(); }
        }

        [DataMember]
        [Required]
        public long Limit { get; set; }

        public override string ToString()
        {
            return "{{License: {0}, LicenseId: {1}, Type: {2}, LimitType: {3}, Limit: {4}}}".FormatWith(Name, Id, Type, LimitType, Limit);
        }
    }
}